/*
 * Sesame Inc.
 * Copyright (c) 2009 All Rights Reserved.
 */
package com.sesame.controller.admin;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import com.sesame.domain.Admin;
import com.sesame.domain.Album;
import com.sesame.domain.User;
import com.sesame.service.AdminService;
import com.sesame.service.AlbumService;
import com.sesame.service.ContactService;
import com.sesame.service.UserService;

/**
 * @author voidman
 * 
 */
public class AdminListController extends AbstractController {

    private AdminService adminService;

    public void setAdminService(AdminService adminService) {
        this.adminService = adminService;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {

        if ("root".equals(request.getSession().getAttribute("adminRank"))) {
            Map model = new HashMap();
            List<Admin> adminList = adminService.listAllAdmin();

            model.put("adminList", adminList);

            return new ModelAndView("admin/adminList", model);
        } else {
            return new ModelAndView("redirect:adminError.html");
        }

    }

}